package com.tecsoluction.transportecerto;

import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class TracarRotas extends MapActivity implements OnClickListener{

	private MapView mapa ;
	private MapController controladorMapa;
	private double longitude;
	private double latitude;


	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setContentView(R.layout.tracar_rotas_layout);
        mapa = (MapView) findViewById(R.id.mapViewTracarRota);
        controladorMapa = mapa.getController();
    
	    	   mapa.setSatellite(false);
	           mapa.displayZoomControls(true); 
	           mapa.setClickable(true);
	           mapa.setBuiltInZoomControls(true);
	    	   LinearLayout linearZoonMapa = (LinearLayout) findViewById(R.id.zoonTracarRotas);
	    	   linearZoonMapa.addView(mapa.getZoomControls());
	           controladorMapa.setZoom(18);  
	           
	           new RotaAsyncTask(mapa).execute(
	           		// Latitude, Logintude de Origem
//	           		-latitude,-longitude,
	           		-22.054885,-44.890455
	           		// Latitude, Longitude de Destino
	           		-23.604262,-46.676513);

	           
	           
    }

    public GeoPoint posicao(double latitude ,double longetude)
	{
		GeoPoint geopoint = new GeoPoint((int)(latitude *1E6), (int)(longitude* 1E6));
		
	
		return geopoint;
	}

	
	public void onLocationChanged(Location location) {
		// TODO Auto-generated method stub
		
	}


	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		String tag="cccccc";
			String msg ="dededededede";
		Log.i(tag, msg);		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		  getMenuInflater().inflate(R.menu.principal_layout, menu);
		        
		        super.onCreateOptionsMenu(menu);
	        menu.add(0,0,0,"escolherDestino");
	        menu.add(0,1,1,"listarParadas");
	        menu.add(0,2,2,"tracarRota");
	        menu.add(0,3,3,"Principal");

		return true;
	}




	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()){

		case 0 : {

			Intent intent = new Intent(TracarRotas.this,EscolherDestino.class);
			startActivity(intent);

		}
		break;

		case 1:{

			// intent que chama mapasParadas
			Intent intent = new Intent(getBaseContext(),MapaParadas.class);
			startActivity(intent);

		}
		break;

		case 2:{
			Intent intent = new Intent(getBaseContext(),TracarRotas.class);
			startActivity(intent);

		}
		break; 
// ESSA PRINCIPAL SE REFERE AO MENU PRINCIPAL
		case 3:{
			Intent intent = new Intent(getBaseContext(),Principal.class);
			startActivity(intent);

		}
		break; 


		}

		return super.onOptionsItemSelected(item);
	}


}
